<!DOCTYPE HTML>
<html>
{include file="public:header_css"}
<body>
<nav class="breadcrumb">
    <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" >
        <i class="Hui-iconfont">&#xe68f;</i>
    </a>
</nav>
<div class="page-container">
    <div class="mt-20">
        <table class="table table-border table-bordered table-hover table-bg table-sort">
            <thead>
            <tr class="text-c">
                <th width="10"><input type="checkbox" name="" value=""></th>
                <th width="60">课程名称</th>
                <th width="60">课程类型</th>
                <th width="60">课任教师</th>
            </tr>
            </thead>
            <tbody>
            {foreach name="course1" item="val" key="key"}
            <tr class="text-c">
                <td><input type="checkbox" value="{$val.course_id},{$val.teacher_id}" name=""></td>
                <td>{$val['course_name']}</td>
                <td>
                    {if $val['course_type'] == 1 }集体{/if}
                </td>
                <td>{$val['teacher_name']}</td>
                <td style="display: none">{$val['teacher_id']}</td>
            </tr>
            {/foreach}

            {foreach name="course2" item="val" key="key"}
            <tr class="text-c">
                <td><input type="checkbox" value="{$val.course_id},{$val.teacher_id}" name=""></td>
                <td>{$val['course_name']}</td>
                <td>
                    {if $val['course_type'] == 2 }一对多
                    {else }一对一
                    {/if}
                </td>
                <td>{$val['teacher_name']}</td>
                <td style="display: none">{$val['teacher_id']}</td>
            </tr>
            {/foreach}
            </tbody>
        </table>
    </div>

    <div class="row cl" style="margin-top: 55px;margin-left: 100px;">
        <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
            <input type="hidden" id="stu_id" value="{$stu_id}">
            <button class="btn btn-primary radius" type="submit" id="submit">&nbsp;&nbsp;删除&nbsp;&nbsp;</button>
            <a class="btn btn-warning radius"  onclick="cancel({$stu_id})">&nbsp;&nbsp;取消&nbsp;&nbsp;</a>
        </div>
    </div>
</div>

{include file="public:footer_js"}

<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="__STATIC__/admin/lib/My97DatePicker/4.8/WdatePicker.js"></script>
<script type="text/javascript" src="__STATIC__/admin/lib/datatables/1.10.0/jquery.dataTables.min.js"></script>
<script type="text/javascript" src="__STATIC__/admin/lib/laypage/1.2/laypage.js"></script>
<script type="text/javascript" src="__STATIC__/admin/lib/laypage/1.2/laypage.js"></script>

<script type="text/javascript">

    /*课程-删除*/
    $("#submit").click(function(){
        var stu_id = $('#stu_id').val();
        //选中课程
        var arr=[];
        //监听按钮
        $.each($('input:checkbox'),function(){
            if(this.checked){
                arr.push($(this).val());
            }
        });

        layer.confirm('确认要删除吗？',function(index){
            $.post(
                "{:url('del')}",
                {
                    stu_id     : stu_id,
                    course_arr : JSON.stringify(arr)
                },
                function (res) {
                    if(res.code === 1){
                        layer.msg(res.msg,{icon:6,time:1000});
                        if(res.data.flag==1){
                            // 两秒后跳转到列表页
                            setTimeout(function () {
                                parent.location.href = "{:url('student_arrange/index')}"+"?stu_id="+res.data.stu_id;
                            },2000);
                        }else{
                            // 两秒后跳转到列表页
                            setTimeout(function () {
                                parent.location.href = "{:url('student/index')}";
                            },2000);
                        }

                    }else{
                        layer.msg(res.msg,{icon:5,time:1000});
                    }
                }
            );
        });
    });

    function cancel(stu_id) {
        layer.msg("取消成功",{icon:6,time:1000});
        parent.location.href = "{:url('student_arrange/index')}"+"?stu_id="+stu_id;
    }
</script>
</body>
</html>